<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/12/17
  Time: 16:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改</title>
    <script type="text/javascript" src="../../js/jquery-3.6.0.js"></script>
</head>
<body>
<h1>修改用户</h1>
<div>
<%--    <form action="#" method="post">--%>
        I   D:<input type="text" id="ID" name="ID" value="${userInfo.id}"><br/>
        用户名：<input type="text" id="NAME" name="NAME" value="${userInfo.userName}"><br/>
        手机号码：<input type="tel" id="PHONE" name="PHONE" value="${userInfo.phone}"><br/>
        邮   箱：<input type="email" id="EMAIL" name="EMAIL" value="${userInfo.email}"><br/>
        密   码：<input type="password" id="PASSWORD" name="PASSWORD" ><br/>
        确认密码：<input type="password" id="ACKPASSWORD" name="ACKPASSWORD" ><br/>
        <input type="submit" value="修改"  onclick="edit()">
<%--    </form>--%>
</div>
    <script type="text/javascript">
        function edit() {
            var id=$("#ID").val();
            var name=$("#NAME").val();
            var email=$("#EMAIL").val();
            var phone=$("#PHONE").val();
            var password=$("#PASSWORD").val();
            var ackpassword=$("#ACKPASSWORD").val();
            $.ajax({
                url:"http://localhost:8065/myblog/userinfo/update",
                type:"post",
                datatype:"json",
                data:{
                    "id": id,
                    "userName": name,
                    "email": email,
                    "phone":phone,
                    "password":password,
                    // "ackpassword":ackpassword
                },success(data){
                    if (data){
                        alert("修改成功");
                    }
                },error(){
                    alert("修改失败");
                }
            })
        }
    </script>
</body>
</html>
